package de.elenore.util;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import de.elenore.render.GameRenderer;
import de.elenore.render.RenderInterface;
import de.elenore.system.InputSystem;
import de.elenore.system.SimulationListener;
import de.elenore.system.SoundSystem;

public class GameActivity extends Activity {
    
    /**
     * Beim Spiel muss von jeder Klasse abgeleitet werden / RenderInterface implementiert werden
     * 
     */

    private GLSurfaceView glsurface;
    private GameRenderer renderer;
    private SoundSystem sound;
    private InputSystem io;

    private int width;
    private int height;


    /**
     * User leitet von Game ab, Der Rest Passiert automatisch
     */

    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	io = new InputSystem(this);
	sound = new SoundSystem(this);
	renderer = new GameRenderer(this);
	glsurface = new GLSurfaceView(this);

	glsurface.setRenderer(renderer);
	glsurface.setOnTouchListener(io);

	this.setContentView(glsurface);
    }

    public int getWidth() {
	return width;
    }

    public int getHeight() {
	return height;
    }

    public SoundSystem getSoundSystem() {
	return sound;
    }

    public void setWidth(int width) {
	this.width = width;
    }

    public void setHeight(int height) {
	this.height = height;
    }

    public void setRenderInterface(RenderInterface ri) {
	renderer.setRenderInferface(ri);
    }

    public void setSimulation(SimulationListener sim) {
	//	io.setSimulation(sim);
	renderer.setSimulation(sim);

    }

    public void setSoundSystem(SoundSystem sound) {
	this.sound = sound;
    }
}
